Shooting from the hip here:
Try replacing the "dmerro" function with the below (I just changed "command" to "command-s")Code - Auto/Visual Lisp: [Select]
); end if (command-s) ;; ^ don't go back unless routine reached UCS change but didn't change it back (command-s "_.undo" "_end") (dmreset) ); end defun