using Generate function in controller