fixed viterbi algorithm