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