remove unused code
fix bug in exporting data