calculating average speed