Added code for speed measurement