move logic to save server config to a better place