added logic to update links where necessary