update the algorithm