Refactoring moveForward and moveBackward

PR3