fix errors in saving