Added check for convergence