updated queri api, better debugging