Second attempt fixing save config funtion. Untested