Further refactor switch processing