MOD: minor modifications to fit function