fix bugs when adding link