fix bugs in save and load function