added the outer most algorithm layer. fixed a couple bugs with find_best_word_inner_function