clean up query.cpp