save function has been improved