refactoring, undoing code duplication