Remove unused variable
Further improve duration detection code