upload refactor