fixed the save function