build randomwalk function