I don't understand how this function works with scoping. I get that it makes it easier for test but how is it actually function in the production code (ie in `_submit_for_retry` it is used)