replace some macros with closures