Refactored download script according to review