more complex pattern matching