Code to measure time elapsed