Fix index function