Find loops in sequence