refactored several methods in program.rb