Update flattening.js