New algorithm to calculate speeds