move addition of getIndex to the end