Macro refactoring