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