Query to Condition refactor