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