fix the error after unflatten