changed calculation of switches