how to use the index function