Refactoring exercises from chapter 5