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