algo. need to check convergence