added new helper function putTerminalIntoMovingState