Bug fix in array index