changed plotting function to one that works