Get rid of too much complicated index logic