Extracted the macros out to a factory