fixed a bug when total=0