made monitor-switch more general