Code refactoring. Downloading doesn't work