added calculation of velocity