calculate boxes' hegiht correctly