Refactoring movingForward and movingBackward