recoded the example using closures, as per Tijs' suggestion - in a separate package to avoid gen clash