fix download, refactoring