refactoring index example