generatefunction