refactor download_packages