fixing threshols computation