implemented the KMP string matching algorithm