PDB-554 simplify retry logic and put it into a method

Signed-off-by: Ken Barber <ken@bob.sh>