Modified code to deal with updated links_data structure