improving save_config function