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