Fix error with array index usage