bug fix in duration calculation