Refactor condition statement