adding support for higher order markov chains