Rewrote speed calculation for ease of reading