working code for word-count, but I really don't like the way I handle the string, replace would be more elegant