Completing chapter 6 exercises