refactor main.rb