use pattern matching