start of func generation code