Fix crash bug in the variable exemption logic