detect cycle in LL