implemented the save method