updated plot code