utils for chain sequences matching