changed code for plotting