refactored downloading