Modified the code to calculate the running time