Updated the algorithm.