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