Save function fixed