Fix bug of calculating total duration