reorder the IF statement a bit