curve fitting now works