refactored condition statement