detect/remove loop in linkedlist