clean up index code a bit