added code to ex2.rb