Modify query design to return shared pointer