added in code to save an R object