refactoring: small code duplication eliminated