Created a save function