reorganized link function