added updateCubes function