corrected flattening repo