Updated the plotting function after the bug fix