refactoring addIndex()