added export functionality (not tested)