add GenerateFunction method