added speed measurement function