add list header
Implement pattern matching algorithm