simplified updated of dupin.rb