Fixed logical error when calculating elapsed time