add my solution to exercise in chapter 9