Refactor native function