move the if condition up