updated switches example for observer pattern