Finished the index function