Finished imperative KMP algorithm part