created save function to replace commonly used steps to save the contents of the library.