repaired linkFunction