moved from macro to templated function