implemented viterbi