upload refactoring