Refactor hw6assignment.rb