Modified movement code to use standard functions