partially functional, some bugs when exporting