Fix the plot function