Refactoring of code to print only a row for each download