update saving logic