final version with macros