Changed order of if statement