implemented save and load function