move some code to read_config