Refactoring export code