Refactors to produce random word and its id.