reordered if statement