refactor retry logic so new casid is captured