Clean up impl of query some more