new, faster select from thresholds
pune unneeded code