Refactoring the construction of the PrimeToWordDictionary