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