brute force recursion. seems to solve everything.