fixed threshold calculation bug