Changed duration logic to work in Firefox.