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