correct a bug in link function