implement query routing and optional parameters