Improve retry handling