runMacro function