finished script to calculate cubes