Pattern matching utilities