add recursive and pattern matching