refactor retry