added --max-chisq flag