Refactored upload procedure