implement smart retry handler