added logic for query sets