bug fixing in viterbi algorithm