Fix probSwitch() function according to expB and speedup file writing