collapsed some functions to macros