subsequences udf