refactoring for DRY