Fixed to use $config["debug"] rather than $debug