Fix broken URLs and check if id exists before performing