pattern matching passes all tests