modified getSizeAndStartOfCubes function