fix save duplicate code