created if statement in function