Add a query-first function