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