duration calculation bug corrected