a bit of cleanup, and a more sophsticated example