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