implimentation of A Gen Function