Updated the plotting code