trying to fix js code for totals