correctly construct riemann query