restructure the link code