Clean up query and add additional comments