code is as posted to the blog