made the upload more robust for the case where refresh is not called.