Refactor of if