fix indexing error