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