Identify split group of elements - fixed buggy code