revised midterm.rb