add traversal function for Markov Chain
fix some indenting