Fix bug in retry code