started refactoring 'if'