working on flattening