Updated the random walks algorithm