Refactor APPEND macro into static function