Move text generation to a method