added a recursive version of adding links