improve pattern finder