Save function bug fixed