switched to reference rather than copy semantics for query on RunQuery