def the query function.