Implementing and refactoring indexes