more robust saving mechanism for plotting