added random walk function