minor change in the algorithm.