Refactored count_words wit proper regular expression