Fixed bug that caused the total values to be calculated incorrectly