improve compareDuration method