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