Add null check for toggling.