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