Updated flatten