fixing Save function