Refactored random word generator into factory