added flattening layered divisve method, to prevent optimum skipping in first layer