First refactor for w1c3.rb