Nested pattern matching