Bug fix for saving logic.