Fixed bug in indexing