Refactor cal.rb