adding in QueryOperation and refactoring underneath a little.