fixed indexing problems