fixing indexing problems