refactor conditional