calcSpeed function comment