use KMP for searching