sort out the kmp