Refactored to allow for macros