Improve the replace word/WORD function