fix calculateDimensions function