refactoring index input