brute force algorithm