Function to if statement