refactored download process