factor out nll_fit from minimize