worked on the plotting function