Fix up switch function, rearrange arrawys