Optimized regions decomposition (still working on faster algorrithm)