commented out some bugs, but added variables for previous positions and directions