Get rid of a duplicated if condition