refactoring to index