reorganize code with read_config() method