Refactor random_walk