converted more chapter 22 examples to Swift