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