first version of threshold_proportional.py