Added counting words function