brute force working code