Modified exercise2.rb