More robust code for removing the link part before the id