Refining the algorithm.