Added the function for cohorts calculation