implement pattern filter