(http://csharppad.com/gist/10856699)