Made markov work better, but still needs a cleanup