Fixed calculation error in bad fit detection