Refactor boilerplate