issue #20445: refactor deeply nested callbacks
Merge pull request #728 from shackbarth/20445-recover

issue #20445: refactor deeply nested callbacks