Refactored utils to use the match_pattern() method.