Develop algorithm further in cal.rb