pattern generation