some refactoring triggered by PR 50611