cleaned up index code slightly