add util function useful to infer repeated pattern