added code that saves the plots