Fixed uploading function