updated the index function