archives uploading code refactored