if statement mess fixed