refactoring prototype for upload.