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