added stopping criterion to solver