The viterbi algorithm working