added save file as tmp and rename it