finding cycle in list