fix save and load logic