refactor conditionals