Refactored the function of generating download URLs