Refactoring for #410