update hmm algorithm