improve templated link matching