added printing code for query