improve pattern selection