fix retry function