refactored main.rb