fix duration logic