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