refined data saving logic.