Code refactoring for upload process.