added viterbi algorithm