restore brute-force algorithm