finished 3.2, added defne pattern matching