Refactored generate_text(), added a default case.