fix bug when no pattern