Updated algorithm to find concatenation offset.