refactor condition