Refactor type match