Use better algorithm for type matching