chapter 1 completed, better solution to 1.6