corrections in algorithm