Fixed one of the bugs associated with the generateSentence function