added fit function