implementing link following and loop detection