Fixing Undefined variable  tid.