Rewrite the algorithm.