Wrong indexing of array is fixed