began the viterbi function