private function safeMove(callable $moveAction)
    {
        $oldPosition = $this->position;

        try {
            return $moveAction();
        } catch (OutOfBoundsException $e) {
            $this->position = $oldPosition;

            throw $e;
        }
    }