Refactor: Common getIndex helper