factor out convergence tester