Improve the controller logic to remember the previous movement.