I think this would work if it didn't run out of memory...