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