Pruning the code down to just the query function.