fixed math bug calculating elapsed time