much better version of viterbi