finished another iteration of function viterbit algorithm, it still needs more cleanup