Refactors the retry to be less generic and more clear