merge two 'if' into one

accept the owner's suggestion, merge two if into one