Modified algo and final output.tsv