Refactor external function macro