refactoring, see #2