refactoring upload process