optimized groupcondition querying