Refactored run_upload functions into single function