Fix error when reaching a dead end in the markov chain