define_condition function refactored