refactored Export a bit (still not great)