get rid of a duplicated if-clause