check if a cycle in the linked list