fixed bug with save/restore