Updating the fitting script (more robust and almost fit-error proof)