improve riemann failures logic