some refactoring with macros