Uploading algorithm (implemented offline)