added code for function code generation. But some error happening, need to debug. If anyone wants to take it up