If statements refactored