struggling with wordcount in functional way