refactor conditions