clean up and simplify market.rb