Fix export algorithm