Fixed small bug in speed threshold calculation