refactor getindex