Could you keep it as a function as it was before and not make it a macro?
macro are not easy to maintain / syntax error check / compile error fix, etc.