Updated version Rated 3 out of 5 stars

Here's an updated version https://gist.github.com/813029