added generate text function