refactor retry (will squash when approved)