fix reference bug in getIndex