finish fit function(simple version)