Move retry logic into generator