Adding conditions to total, bugfix