rewrote resave_plots with documentation