fix bug in retry code