fixed last if statement