replaced flatten