made some progress with the switch function.