implemented new flattening