Fixing the check for existing variable validation