Addded save function