Do we need the factory or could its logic be directly implemented in Queries.wrap?