Optimization of cuboid