move if clause further out