Speed up the brute force method.