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