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