add kmp implementation for pattern matching