with pattern generation and search