Fix Brute force algorithm