refactor parse_config() function to make it DRY