refactor method creating macros