Correct the HMM algorithm.