Refactored match_type_id using pattern matching.