made number_of_words functional