implemented methods to detect cycle, split the entity and update the links