solve the cannot match last word bug