fix bug calculating difference in speed