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