Why do you use global var instead of passing params to the segmentation function?