refactored the export script