improve query API