modifying the logic of querying the Link model, in the first db-hit