tweaked the duration logic