Fix switchprefecrence bugs with more than 3 switches

Change-Id: I5f8df2f86a3cf39dbc0cd26359d4c476585c40c1