fixed bad indexing value