tweaks to match_tir subroutine