Corrected bug in indexing