Should be O(n^3) on a good day ;)