simple refactoring
more refactoring: reduce code duplication