detect cycle in linked list