Calculating total time