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