wordcount implementation