issue #20445: refactor deeply nested callbacks