added main function and curve fitting