Correcting algorithm.