fixed undefined in printQuery