fixed potential divide by 0 problem in avg_speed()