more refactoring for #11