added option to save as tsv or json