Add $debug variable and use it