fix #3728: improve contact matching