updated code, writes tsv