turn cal_improve.rb into java