merge_betas function added