now generate closures programmatically