fix logic issue with retries