Implemented Viterbi