refactor downloading