added some new code for plotting