add save and plot functionality