Fix 'undefined variable  errors'