Calculating speed and position