looping through words to determine count