new template based macro code