Perhaps move this to just before line 27 below so both calls can be in the retry loop.