extracted link reference logic to helper method