hash now keeps track of prior words
Program functions with proper backtracking