updated the query api, better debugging