fix the threshold_function