Refactor download