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