KMP algorithm bug fixed