Fix bug: modify get duration function