fixed bug in kmp