   (save-excursion
     (let* ((name (buffer-substring-no-properties (region-beginning) (region-end)))
            (short (buster--global-shortcut name))
-           end)
+           beg end)
       (unless (search-backward-regexp js--iife-regexp)
         (error "No immediately invoked function expression found."))
       (deactivate-mark)

      (unless (looking-at ")")
        (insert ", "))
      (search-forward "{")
      (backward-char)
      (forward-list)
      (forward-char)

      (insert name)
      (unless (looking-at ")")
        (insert ", "))
      (replace-string name short t beg end))))

(provide 'javascript-defuns)
