add 2 row matrix threshold distance func