refactor prepare.rb