Separate _cfg and _proc logic in scripting for better readability and flexibility