save function improved.