refactoring for less boilerplate