small refactoring to keep code dry