Refactoring of PR #8833