Fixed the wander function