refactored where condition determination