Update generate() function to return string instead of printing result