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