fixed speed calculation bug