Added guard for duration computation