program1 (http://csharppad.com/gist/9277712)