Fixing exception in _isMainKey()