cleaned up index2 code a bit more