Cleaned up Index code