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