corrected indexing error