fixed bugs on save twice