refactored upload and download methods