Adding conditions to total