cleaned up index code