Refactor IfStatement