added function countWords