refactor indexing