Refactor the type switch processings