update fitting code and plotting code