Improved template with macros