change if statement in index function