Refactoring for #2