fixed bugs with $total