Added possibility to stop loops when algo converges