change counting words logic