correct the plot function