fix onGenerate function to be triggered