chapter14: some refactoring