Added extra conditions to retry logic