fixing totaling logic