 
                   ;; (message "OLD CURSOR %s NEW CURSOR %s" cursor new-cursor)
 
-                  (when overlay (delete-overlay overlay))
+                  (emc-delete-cursor-overlay cursor)
                   (emc-delete-region-overlay region)
-                  ;; (when region (delete-overlay (emc-get-region-overlay region)))
 
                   (setq new-cursor
                         (emc-put-cursor-overlay

                  (setq cursor-list
                        (emc-insert-cursor-into-list
                         new-cursor cursor-list)))))


            ;; (setq new-cursor (emc-put-cursor-overlay
            ;;                   new-cursor (emc-draw-cursor-at-point-old)))
            ;; (setq cursor-list (cons new-cursor cursor-list)))))

            ;; TODO the cursor-list must be sorted by the start position
            ;;      instead of reverse just use emc-insert-cursor above
            (setq emc-cursor-list cursor-list))
          ;; (message "cursors %s" (mapcar 'emc-get-cursor-start emc-cursor-list))
          ;; (emc-command-reset)


(defun emc-before-cursors-setup-hook ()
  "Hook to run before any cursor is created."
  (message "before cursors hook")
  (evil-jumper-mode 0))

(defun emc-after-cursors-teardown-hook ()
  "Hook to run after all cursors are deleted."
  (message "after cursors hook")
  (evil-jumper-mode t))

(defun emc-init-mode ()
  "Initialize the evil-multiple-cursors mode."
