add comments of pattern matching for function