use old-school kmp instead of smart's implementation