somewhat cleaner but O(n**2) reassociator