brute force algorithm
seems to work, but takes too long, with so many possibilities