Improving Kain-Fritsch convective parameterization using direct calculations of entrainment and detrainment in shallow and deep convection