refactor indexOf