little improvements

Using  input formats and a feature new in 2.1 and recycling to simplify the code a bit. I hope you enjoy it. I am not expecting you to merge, you probably want to keep your repo aligned with the blog post. This is just so that you can take a look at the changes.