fixing unflatten