fix bugs in local.matching