moving helper functions to macros