fixed error with indexing