changed the last if statement to an else