Modified viterbi hash to fit slightly more situations