refactoring main2.rb