Refactored download into method (lines 44-49)