implemented pattern mode