Changes based on an example by Christian Weiske