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