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