chapter 5 - pattern matching example