analysis and plotting improved