refactored upload_library