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