refactoring code, to make upload object