fixed fitting script (change thresh)