Refactor: replace macro with inline function