Additional code for blog post of same title at qmaurmann.wordpress.com