Fix infinite retry logic