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