implemented pattern validation