Refactor Boyer-Moore implementation