simplified cal.rb
further refactoring