Fix speed calculation bug