script optomization for a detach and rename MacroScript

Hi All,

I am very new to 3ds Max and Maxscript and I am working on a MacroScript for a UI Toolbar Button. It detaches selected polygons from an object and renames them with the original object name and a prefix of "R_". The script is below.

The script works, but there is a delay and I was wondering if there were any techniques or different ways of doing things that could speed up the process. Thanks in advance.

macroScript Detach_Name category:"CH"

(
s = getCurrentSelection()
b = for obj in s collect obj.name
$.modifiers[#Edit_Poly].ButtonOp #DetachFace
select $obj*
for obj in $ do obj.name = "R_"+b[1]
)