Final flatten, I still don't know why first version didn't work