added equation to calculate speed