Abstract out the new query functionality.