finished converting chapter 16 examples to Swift