Complete matching algorithm in link.lua