move util functions to a macro