lots of changes for plotting