It feels to me like this stanza/paragraph should be able to be DRYed up with its near-clone outside the until-block.
For example, it's unclear to me why the hits_total variable isn't being incremented in here like the outside copy was.