added detection for tab activation and removal