Fix bug. Now the loop ends when fails to converge.