Refactoring for #38