Implement query API