Use when with comma
Switching Array to Map
Save file
State changes
Restore state
Restore state
Get state; write file only on state change