flat script has been updated to perform our tasks: now can unflat structures with different deep;