still need the min value fix in cpp